﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObjects.BO_GetObjects;
using System.IO;
using DigiLib;

public partial class Administrator_Controls_SmsCmdCodeExtsAdd : Admin_Controls_Base {
    protected void Page_Load(object sender, EventArgs e) {
        base.removeHGC(divMessage);
        if (!IsPostBack) {
            base.bindDDL(ddParent, BO_portal_sms_cmd_code.Inside(0), "CMD_CODE", "CMD_CODE_ID");
            ddParent.SelectedValue = Category_ID.ToString();
            txtOrder.Text = SqlUtils.GetNextOrderDisplay("portal_sms_cmd_code_exts").ToString();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e) {
        try {
            string content = txtContent.Text.Trim();
            string exclude = txtExclude.Text.Trim();
            int smscode = Convert.ToInt32(ddParent.SelectedValue);
            int Order = Convert.ToInt32(txtOrder.Text.Trim());
            string strResult = BO_portal_sms_cmd_code_exts.Insert(
                                                                smscode,
                                                                content,
                                                                exclude,
                                                                Order,
                                                                DateTime.Now,
                                                                Administrator.USER_NAME,
                                                                DateTime.Now,
                                                                Administrator.USER_NAME,
                                                                true);
            if (strResult != "0")
                divMessage.InnerHtml = MessageBox.Success("Hệ Thống", "Thêm mới menu hệ thống thành công!");
            else
                divMessage.InnerHtml = MessageBox.Error("Hệ Thống", "Có lỗi trong quá trình xử lý, thử lại sau!");
            base.Clear(this.Controls);
        } catch (Exception ex) {
            divMessage.InnerHtml = MessageBox.Error("Lỗi", "Phát hiện lỗi xảy ra !<br />" + ex.Message);
        }

    }
}
